home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 276-300 / 297 / clean / clean.asm < prev    next >
Assembly Source File  |  1995-03-14  |  8KB  |  242 lines

  1. ****************************************************************************
  2. *                  ***  Clean V1.0 (c) 1989 By Dan Burris  ***             *
  3. *                                       *
  4. * This is a program to clean your Floppy diskettes, it has protection from *
  5. * trying to write to anything other than DF something, and only 0 thru 3,  *
  6. * and then only if that drive is connected to the Amiga that it is running *
  7. * on.                                       *
  8. *                                        *
  9. * I hereby declare this program to be in the Public domain.  You may use   *
  10. * in your programs including commercial or whatever, as long as you do not *
  11. * use it maliciously, or blame ME for any of it's failures, or misgivings! *
  12. ****************************************************************************
  13.  
  14.  
  15. ****    Equates and Offsets    ****
  16.  
  17. OpenLibrary        EQU     -408
  18. CloseLibrary       EQU     -414
  19. ExecBase       EQU     4   
  20.  
  21. ****    Amiga Dos Calls    ****
  22.  
  23. Open           EQU     -30
  24. Close          EQU     -36
  25. OpenDevice     EQU     -444
  26. CloseDevice       EQU     -450
  27. SendIO         EQU     -462
  28. Delay        EQU    -198
  29. Read           EQU     -42
  30. Write          EQU     -48
  31. WaitForCh      EQU     -204
  32. mode_old       EQU     1005
  33. OutPut        EQU    -60
  34. Exit        EQU    -144
  35. Lock        EQU    -84
  36.  
  37. run:
  38.     move.l    d0,d4            ;save length of Parameter
  39.     move.l    a0,a1            ;save Parameter address
  40.     move.l    #whodisk,a5        ;address of drive name in a5
  41. getit    move.b    (a1)+,(a5)+        ;save Parameter in whodisk
  42.     dbra     d0,getit        ;until all in whodisk
  43.     cmpi.b     #4,d4            ;was Parameter -  df#:?
  44.     bne    Template        ;tell user how to use, & exit
  45.             
  46.     bsr      init                  ;Initialization-Open stuff
  47.     bra      ScreenOut        ;Print Msgs, and work
  48.  
  49. init:                                    ;System initialization and Open
  50.       move.l     ExecBase,a6            ;Pointer to  EXEC-library
  51.      move.l     #dosname,a1        ;Dos Library name in a1
  52.      moveq      #0,d0            ;Version # = don't care
  53.      jsr        OpenLibrary(a6)      ;Open DOS-Library
  54.      move.l     d0,dosbase        ;Save the Address of the Dos
  55.      beq      Clean1            ;Bad open - set flag, and exit
  56.  
  57. OpenTrkDsk:
  58.     lea     diskio,a1        ;Pointer to I/0 structure in a1
  59.      move.l     #diskrep,14(a1)        ;Address of I/O Port in A1 + 14
  60.     move.l    #whodisk,a5        ;Address of drive name in a5
  61.     clr.l    d0            ;Clear d0 to do byte operation
  62.     move.b    2(a5),d0        ;Put ascii drive number in d0
  63.     sub.b    #$30,d0            ;Convert to Actual Drive Number
  64.     cmpi.b    #4,d0            ;Too Large of drive number?
  65.     bge    Template        ;Tell user to start over
  66.      clr.l      d1            ;No Flags
  67.     move.l     #trddevice,a0        ;Put device name in a0
  68.     jsr        OpenDevice(a6)         ;Open trackdisk.device
  69.     tst.l      d0            ;Was it a good Open?
  70.     bne      BadDrive        ;If so,Bad Drive Number-Exit
  71.  
  72. RawOpen:
  73.     lea        RAWname(pc),a1         ;RAW-Definition
  74.     move.l     #mode_old,d0        ;The Mode you use
  75.     bsr      Openfile              ;RAW Open
  76.     beq      CleanUp            ;Error handling routine
  77.      move.l     d0,rawhandle        ;Save the address of the Window
  78.      rts
  79.  
  80. Template:
  81.       move.l     ExecBase,a6            ;Pointer to  EXEC-library
  82.      move.l     #dosname,a1        ;Dos Library name in a1
  83.      moveq      #0,d0            ;Version # = don't care
  84.      jsr        OpenLibrary(a6)      ;Open DOS-Library
  85.     move.l    d0,dosbase        ;save DOS address
  86.     move.l     dosbase,a6        ;Address of the Dos->A6
  87.     jsr    OutPut(a6)        ;get CLI window handle
  88.     move.l  d0,d1            ;save CLI handle
  89.     lea    TempMsg(pc),a0        ;Start of the message
  90.     move.l    #TempMsg1,d3        ;End of message to print
  91.     bsr       print2            ;Routine to print message above    
  92.     jsr    Exit(a6)        ;Exit program!
  93.     
  94. ScreenOut:
  95.     lea    message(pc),a0        ;Start of the message
  96.     move.l    #message1,d3        ;End of message to print
  97.     bsr    print            ;Routine to print message above
  98. NoRemove:
  99.     move.l    ExecBase,a6        ;Start of Exec Library in a6
  100.     lea    diskio,a1        ;Pointer to I/O Structure in A1
  101.     move.l    #0,40(a1)        ;To shut off disk remove spin
  102.     move.l    32(a1),d7        ;IO_ACTUAL in d7
  103.     move    #12,28(a1)        ;Command = Toggle motor on/off    
  104.     move.l    #1,36(a1)        ;Turn DFO disk drive motor on!
  105.     move.l    #1,d0            ;Drive #1
  106.     jsr    SendIO(a6)        ;Send the command to the drive    
  107.  
  108. GetKey:
  109.     move.l    #inbuff,d2        ;Address of Input Buffer
  110.     move.l    #1,d3            ;Number of characters to read
  111.     move.l    dosbase,a6        ;Find Dos Library
  112.     move.l    rawhandle,d1        ;The Place to get keypress from
  113.     jsr    Read(a6)        ;Get 1 character
  114.     move.b    inbuff,d0        ;Put it in d0
  115.     moveq    #$1b,d4            ;ESC character in d4
  116.     cmp.b    d4,d0            ;Was it ESC key?
  117.     beq    CleanUp            ;If so close Libraries and Exit
  118.     moveq    #$0d,d4            ;Return character in d4
  119.     cmp    d4,d0            ;Was it Return?
  120.     bne    GetKey            ;Bad input, start over.
  121.     
  122. MotorOn:
  123.     lea    MotorMsg(pc),a0        ;Address of MotorMsg in a0
  124.     move.l    #MotorMsg1,d3        ;Address of end of MotorMsg
  125.     bsr    print            ;Print it
  126.     move.l    ExecBase,a6        ;Start of Exec Library in a6
  127.     lea    diskio,a1        ;Pointer to I/O Structure in A1
  128.     move.l    32(a1),d7        ;IO_ACTUAL in d7
  129.     move    #9,28(a1)        ;Command = Toggle motor on/off    
  130.     move.l    #1,36(a1)        ;Turn DFO disk drive motor on!
  131.     move.l    #1,d0            ;Drive #1
  132.     jsr    SendIO(a6)        ;Send the command to the drive
  133.     move.l    #750,d1                ;Delay() parameter - 15 seconds
  134.     jsr    Wait            ;Wait 15 secs. while spinning
  135.  
  136. MotorOff:
  137.     move.l    ExecBase,a6        ;Start of Exec Library in a6
  138.     lea    diskio,a1        ;Pointer to I/O Structure in A1
  139.     move.l    32(a1),d7        ;IO_ACTUAL in d7
  140.     move    #9,28(a1)        ;Command = Toggle motor on/off    
  141.     move.l    #0,36(a1)        ;Turn DFO disk drive motor off!
  142.     jsr    SendIO(a6)        ;Send the command to the drive
  143.     bra    CleanUp            ;Close Libraries and exit
  144.     
  145. CleanUp:
  146.     move.l     rawhandle,d1         ;Handle to RAW
  147.     move.l     dosbase,a6        ;Dos Library Close
  148.      jsr        Close(a6)        ;Close Window
  149. Clean1:
  150.     move.l     dosbase,a1            ;DOS.Lib Close
  151.     move.l     ExecBase,a6        ;Address of Exec in a6
  152.     jsr        CloseLibrary(a6)    ;Close Dos Library
  153. Clean2:
  154.     lea        diskio,a1        ;Address of Trackdisk
  155.     move.l     32(a1),d7        ;IO_ACTUAL in d7
  156.      jsr        CloseDevice(a6)        ;Close TrackDisk Device
  157.     rts
  158.     
  159. BadDrive:
  160.       move.l     ExecBase,a6            ;Pointer to  EXEC-library
  161.      move.l     #dosname,a1        ;Dos Library name in a1
  162.      moveq      #0,d0            ;Version # = don't care
  163.      jsr        OpenLibrary(a6)      ;Open DOS-Library
  164.     move.l    d0,dosbase        ;save DOS address
  165.     move.l     dosbase,a6        ;Address of the Dos->A6
  166.     jsr    OutPut(a6)        ;get CLI window handle
  167.     move.l  d0,d1            ;save CLI handle
  168.     lea    BadMsg(pc),a0        ;Start of the message
  169.     move.l    #BadMsg1,d3        ;End of message to print
  170.     bsr       print2            ;Routine to print message above    
  171.     jsr    Exit(a6)        ;Exit program!
  172.     
  173.             
  174. Openfile:                              ;Open File
  175.     move.l     a1,d1                ;I/O Pointer - Filename
  176.     move.l     d0,d2            ;Mode for the Open
  177.     move.l     dosbase,a6        ;Address of Dos in A6
  178.         jsr        Open(a6)        ;Open the file
  179.     tst.l      d0            ;Was it a good open?
  180.     rts                
  181.     
  182. print:
  183.     move.l    rawhandle,d1        ;Output Window in D1
  184. print2:    move.l  a0,d2            ;Address of Text in d2
  185.     move.l  dosbase,a6        ;Address of Dos in A6
  186.     jsr    Write(a6)        ;Write Message to Window
  187.     rts    
  188.  
  189. Wait:
  190.     move.l    dosbase,a6        ;Find the Dos Library
  191.     jsr    Delay(a6)        ;Wait 30 seconds(drive spins)
  192.     rts
  193.     
  194. RAWname:  dc.b 'RAW:65/35/490/120/'
  195.       dc.b ' Dan',$27,'s Drive Cleaner V1.0 ',0
  196.  
  197.       
  198.  
  199. message:     
  200.          dc.b $0c,$0a,$0d,$9b,'7;32;43m'
  201.          dc.b $9b,'15C'
  202.          dc.b $20,$20,'   The Drive Cleaner   ',$20,$20
  203.          dc.b $0a,$0d,$9b,'0m'
  204.          dc.b $9b,'15C'
  205.          dc.b $9b,'7;32;43m'
  206.          dc.b $20,$20,$20,'© 1988 By Dan Burris ',$20,$20,$20 
  207.          dc.b $0a,$0a,$0a,$0d,$9b,'0;31;40m'
  208.          dc.b '  Please Insert a Prepared Cleaning Disk in '
  209.          dc.b $9b,'4;31;40mDrive '
  210. whodisk      ds.b 4
  211.          dc.b $0a,$0d,$0a,$0d
  212.          dc.b $9b,'0;31;40m'
  213.          dc.b '  And Press Return (Or Press Esc to Exit). '
  214.          dc.b $9b,$30,$20,$70
  215. message1     EQU *-message
  216.  
  217. MotorMsg     dc.b $0a,$0a,$0a,$0d
  218.          dc.b $9b,'0;32;40m                    ***  '
  219.          dc.b $9b,'0;4;33;40mWorking'
  220.          dc.b $9b,'0;32;40m  ***'
  221. MotorMsg1    EQU *-MotorMsg 
  222.  
  223. BadMsg     dc.b 'That Drive is Not Connected to this Amiga!',$0d,$0a
  224. BadMsg1    EQU *-BadMsg
  225.  
  226. TempMsg         dc.b 'Please Type ->  Clean [DF0,DF1,DF2, or DF3]',$0d,$0a
  227. TempMsg1     EQU *-TempMsg
  228.  
  229. dosname:     dc.b 'dos.library',0,0
  230.           cnop 0,2
  231.  
  232. trddevice:   dc.b 'trackdisk.device',0
  233.           cnop 0,2
  234.         
  235. dosbase:     dc.l     0        ;DOS base address
  236. rawhandle:   dc.l     0        ;Window Handle        
  237. inbuff:      ds.b     8        ;Keyboard Buffer
  238. diskio:      ds.l      20         ;I/O Structure
  239. diskrep:     ds.l     8        ;I/O Port
  240.  
  241.           end
  242.